import { reqGetTradeListData } from "../../api/index";

const state = {
  tradeInfo:{}
}
const actions = {
  // 1. 获取trade页面中的数据
  async getTradeListData({commit}) {
    const result = await reqGetTradeListData()
    if (result.code === 200) {
      commit('SAVE_TRADE_INFO_DATA',result.data)
    } else {
      console.log(result.message)
    }
  }
}
const mutations = {
  SAVE_TRADE_INFO_DATA(state,tradeInfo) {
    state.tradeInfo = tradeInfo
  }
}
const getters = {
  detailArrayList(){
    return state.tradeInfo.detailArrayList
  },
  originalTotalAmount(){
    return state.tradeInfo.originalTotalAmount
  },
  totalAmount(){
    return state.tradeInfo.totalAmount
  },
  totalNum(){
    return state.tradeInfo.totalNum
  },
  tradeNo(){
    return state.tradeInfo.tradeNo
  }
}
export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}